/**
 * name: 微应用名称 - 具有唯一性
 * entry: 微应用入口 - 通过该地址加载微应用，这里我们使用 config 配置
 * container: 微应用挂载节点 - 微应用加载完成后将挂载在该节点上
 * activeRule: 微应用触发的路由规则 - 触发路由规则后将加载该微应用
 */
import useAppStore from "@/store/modules/app";
export const setLoading = (loadingState) => {
  useAppStore().qiankunLoading = loadingState;
};
export const microAppConfig = [
  {
    id: "goods",
    name: "goods",
    entry: import.meta.env.VITE_MICRO_GOODS,
    container: "#goods",
    activeRule: '/goods',
    loader: (loading) => setLoading(loading),

  },
  {
    id: "permission",
    name: "permission",
    entry: import.meta.env.VITE_MICRO_PERMISSION,
    container: "#permission",
    loader: (loading) => setLoading(loading),
    activeRule: '/permission',
    // activeRule: location => location.pathname.startsWith(import.meta.env.VITE_MICRO_PERMISSION_RULE),
  },
  {
    id: "purchase",
    name: "purchase",
    entry: import.meta.env.VITE_MICRO_PURCHASE,
    container: "#purchase",
    loader: (loading) => setLoading(loading),
    activeRule: '/purchase',
    // activeRule: location => location.pathname.startsWith(import.meta.env.VITE_MICRO_PURCHASE_RULE),
  },
  {
    id: "wms",
    name: "wms",
    entry: import.meta.env.VITE_MICRO_WMS,
    container: "#wms",
    loader: (loading) => setLoading(loading),
    activeRule: '/wms',
    // activeRule: location => location.pathname.startsWith(import.meta.env.VITE_MICRO_WMS_RULE),
  },
  {
    id: "oms",
    name: "oms",
    entry: import.meta.env.VITE_MICRO_OMS,
    container: "#oms",
    loader: (loading) => setLoading(loading),
    // activeRule: location => location.pathname.startsWith(import.meta.env.VITE_MICRO_OMS_RULE),
    activeRule: '/oms',
  },
  {
    id: "head_procedure",
    name: "head_procedure",
    entry: import.meta.env.VITE_MICRO_HEAD_PROCEDURE,
    container: "#head_procedure",
    loader: (loading) => setLoading(loading),
    activeRule: '/head_procedure',
    // activeRule: location => location.pathname.startsWith(import.meta.env.VITE_MICRO_HEAD_PROCEDURE_RULE),
  },
  {
    id: "tms",
    name: 'tms',
    entry: import.meta.env.VITE_MICRO_TMS,
    container: "#tms",
    loader: (loading) => setLoading(loading),
    activeRule: '/tms',
  },
  {
    id: "base",
    name: 'base',
    entry: import.meta.env.VITE_MICRO_BASE,
    container: "#base",
    loader: (loading) => setLoading(loading),
    activeRule: '/base',
  },
  {
    id: "crm",
    name: 'crm',
    entry: import.meta.env.VITE_MICRO_CRM,
    container: "#crm",
    loader: (loading) => setLoading(loading),
    activeRule: '/crm',
  },
  {
    id: "pmc",
    name: 'pmc',
    entry: import.meta.env.VITE_MICRO_PMC,
    container: "#pmc",
    loader: (loading) => setLoading(loading),
    activeRule: '/pmc',
  },
  {
    id: "publish",
    name: 'publish',
    entry: import.meta.env.VITE_MICRO_PUBLISH,
    container: "#publish",
    loader: (loading) => setLoading(loading),
    activeRule: '/publish',
  },
  {
    id: "fms",
    name: 'fms',
    entry: import.meta.env.VITE_MICRO_FMS,
    container: "#fms",
    loader: (loading) => setLoading(loading),
    activeRule: '/fms',
  },
];
